import pandas as pd

# 1.读取数据
stock = pd.read_csv("../../resources/p00_data_mining/stock_day.csv")

p_change = stock["p_change"]

# 2.自定义分组
bins = [-100, -7, -5, -3, 0, 3, 5, 7, 100]
sr = pd.cut(p_change, bins)

# 3.离散化 one-hot
stock_change = pd.get_dummies(sr, prefix="rise")

# 4.处理好的one-hot编码与原数据合并
pd.concat([stock, stock_change], axis=1) # 列索引合并，行值*2
pd.concat([stock, stock_change], axis=0).head()

